<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">
		<fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<label class="layui-form-label">申请人</label>
						<div class="layui-input-inline">
							<select id="user_id" lay-verify="required" lay-search="" autocomplete="off">
								<option value="" >直接选择或搜索选择</option>
								{volist name="user_list" id="vo"}
									<option value="{$vo.id}" >{$vo.username}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<button type="button" class="layui-btn layui-btn-primary"  onclick="get_ss()"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset>
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
		<script type="text/html" id="currentTableBar">
			
			<a style="{{d.accountant_id?'display:none;':''}}{{d.status==3?'display:none;':''}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="audit">审核</a>
			<a style="{{d.accountant_id?'':'display:none;'}}{{d.status==3?'display:none;':''}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">出纳</a>
			<a style="{{d.status==3?'display:none;':''}}" class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">驳回</a>
		</script>
		<script type="text/html" id="typeTableBar">
			{{d.type == 1?'报销':''}}
			{{d.type == 2?'预支':''}}
		</script>
		<script type="text/html" id="statusTableBar">
			{{d.status == 0?'驳回':''}}
			{{d.status == 1?'审核中':''}}
			{{d.status == 2?'放款中':''}}
			{{d.status == 3?'完成':''}}
		</script>
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
//出纳
function save_cashier(id){
	layer.open({
        type: 2,
        title:'信息',
        area: ['60%', '70%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('cashier_pass')}?id="+id
    });
    //layer.full(index);
}
	var $,form,table,laydate
	layui.use(['form', 'table', 'tableSelect', 'laydate'], function () {
		$ = layui.jquery , form = layui.form , table = layui.table , laydate = layui.laydate

		table.render({
			elem: '#currentTableId',
			id:'list_claim',
			url: '{:url("list_claim")}?t=json',
			method : 'post',
			toolbar: true,
			cols: [[
				{ field: 'create_time', title: '提交日期',width:180},
				{ field: 'type', title: '类型',toolbar: '#typeTableBar',width:100},
				{ field: 'title', title: '提交类别' ,width:180},
				{ field: 'money', title: '金额',width:100},
				{ field: 'remark', title: '费用明细' ,width:200},
				{ field: 'screenshot_url', title: '申请凭证',width:100,  templet: function(d){
			          return d.screenshot_url?'<img  src="'+d.screenshot_url+'">':''
			    }},
			    { field: 'remark', title: '收款账号',width:200, templet: function(d){
			          return d.bank_name+' '+d.number
			    } },
			    { field: 'accomplish_url', title: '打款凭证',width:100,templet: function(d){
			          return d.accomplish_url?'<img  src="'+d.accomplish_url+'">':''
			    } },
			    { field: 'status', title: '状态',width:100,toolbar: '#statusTableBar' },
			    { field: 'user_name', title: '申请人',width:180},
			    { title: '操作', minWidth: 150, fixed: 'right', toolbar: '#currentTableBar',align:'center'}
			]],
			limit: 30,
			page: true,
			skin: 'line'
		});

		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'edit':
					save_cashier(data.id);
				break;
				case 'delete':
					layer.prompt({
						  formType: 2,
						  title: '请输入驳回原因',
						  area: ['400px', '150px'] //自定义文本域宽高
						}, function(value, index, elem){
							layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
							$.post("{:url('bohui_apply')}?t=json",{id:data.id,str:value},function(da){
								layer.closeAll();
								if(da['code'] == 1){
								 //重载数据表格
								 get_apply(da['msg']);
								}else{
								 layer.msg(da['msg'], { icon : 5 });
								}
							});
						});
				break;
				case 'audit':
					layer.confirm('是否通过审核，请确认', function(index){
						get_audit(data.id)
						});
				break;
			}
			//提交审核
			function get_audit(id){
				layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
				$.post("{:url('audit_pass')}?t=json",{id:id},function(da){
					layer.closeAll();
					if(da['code'] == 1){
					 //重载数据表格
					 get_apply(da['msg']);
					}else{
					 layer.msg(da['msg'], { icon : 5 });
					}
				});
			}
			
		});
		//监听行单击事件
		table.on('row(currentTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});

	});
	function get_apply(msg){
		table.reload('list_claim', {
			  url: '{:url("list_claim")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
	function get_ss(){
		var uid = $('#user_id').val();
		table.reload('list_claim', {
			  url: '{:url("list_claim")}?t=json',
			  where:{uid:uid}
			});
	}
	
</script>

</body>
</html>